import Vue from 'vue'
import './cube-ui'
import App from './App.vue'
import router from './router'
import store from './store'
import 'amfe-flexible'
import './public-path'
import '@/mixin/beforeRouteLeave'
import api from '@/request/index.js'  //导入api接口
import message from '@/plugins/message'  //提示弹窗
Vue.prototype.$api = api

Vue.config.productionTip = false

Vue.use(message)
let instance = null;

function render(props) {

    if (window.__POWERED_BY_QIANKUN__) {
        Vue.prototype.$app = props.app;
    }
    if (!window.__POWERED_BY_QIANKUN__ && (process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'uat')) {
        const vConsole = new VConsole();
    }
    instance = new Vue({
        router,
        store,
        render: h => h(App)
    }).$mount('#app');
}

/**
 * 不存在主应用时可直接单独运行
 */
if (!window.__POWERED_BY_QIANKUN__) {
  render();
}

export async function bootstrap() {
    console.log('开始')
}

/**
 * 应用每次进入都会调用 mount 方法，通常我们在这里触发应用的渲染方法
 */
export async function mount(props) {
  render(props);
}

/**
 * 应用每次 切出/卸载 会调用的方法，通常在这里我们会卸载微应用的应用实例
 */
export async function unmount() {
  instance.$destroy();
  instance = null;
}
